import request from './request'

/**
 * Donor related API
 */
export const donorAPI = {
  /**
   * Get donor list
   * @param {Object} params - Query parameters
   * @param {number} params.page - Page number
   * @param {number} params.pageSize - Items per page
   * @param {string} params.blood_type - Blood type filter
   * @param {string} params.keyword - Keyword search
   */
  getList(params) {
    return request({
      url: '/donors',
      method: 'get',
      params
    })
  },

  /**
   * Get donor details
   * @param {number} id - Donor ID
   */
  getDetail(id) {
    return request({
      url: `/donors/${id}`,
      method: 'get'
    })
  },

  /**
   * Create donor
   * @param {Object} data - Donor information
   */
  create(data) {
    return request({
      url: '/donors',
      method: 'post',
      data
    })
  },

  /**
   * Update donor information
   * @param {number} id - Donor ID
   * @param {Object} data - Updated information
   */
  update(id, data) {
    return request({
      url: `/donors/${id}`,
      method: 'put',
      data
    })
  },

  /**
   * Delete donor
   * @param {number} id - Donor ID
   */
  delete(id) {
    return request({
      url: `/donors/${id}`,
      method: 'delete'
    })
  },

  /**
   * Get donor's offspring count
   * @param {number} id - Donor ID
   */
  getOffspringCount(id) {
    return request({
      url: `/donors/${id}/offspring_count`,
      method: 'get'
    })
  },

  /**
   * Get donor's vial list
   * @param {number} id - Donor ID
   */
  getVials(id) {
    return request({
      url: `/donors/${id}/vials`,
      method: 'get'
    })
  },

  /**
   * Get donor's medical screening records
   * @param {number} id - Donor ID
   */
  getScreenings(id) {
    return request({
      url: `/donors/${id}/screenings`,
      method: 'get'
    })
  }
}

